﻿@namespace BootstrapBlazor.Components
@typeparam TModel
@inherits BootstrapComponentBase

<CascadingValue Value="@EditorItems" IsFixed="true">
    @FieldItems?.Invoke(Model)
</CascadingValue>

@if (FirstRender)
{
    <div class="ef-loading">
        <Spinner Color="Color.Primary" />
    </div>
}
else
{
    <div class="form-body">
        <div class="@FormClassString">
            <CascadingValue Value="this" Name="EidtorForm">
                @foreach (var item in FormItems)
                {
                    var render = GetRenderTemplate(item);
                    @if (render != null)
                    {
                        @render(Model)
                    }
                    else
                    {
                        <div class="@GetCssString(item)">
                            @AutoGenerateTemplate(item)
                        </div>
                    }
                }
            </CascadingValue>
        </div>
    </div>
    @if (Buttons != null)
    {
        <div class="form-footer">
            @Buttons
        </div>
    }
}
